
(function () {
    var core = ecui,
        util = core.util,
        ui = ecui.ui,
        dom = ecui.dom;

    Object.assign(
        NS.data,
        {
            headraisings: [],
            unitList: []
        }
    );
    Object.assign(
        NS.ui,
        {
            AddBookBtn: ecui.inherits(
                ui.Control,
                {
                    onchange: function (event) {
                        console.log(event);
                    }
                }
            )
        }
    );
    ecui.esr.addRoute('edit', {
        model: function (context, callback) {
            var model = [
                'unitList@JSON /erp-management/unit/list?pageNo=1&pageSize=999999',
            ];
            if (context.id) {
                model.push('detail@GET /erp-management/expense/detail/${id}');
            }
            ecui.esr.request(model, callback, function () {
                return true;
            });
            return false;
        },
        weight: 3,
        frame: true,
        onbeforerequest: function (context) {
            context.num = mao.util.getTimeRandom();
        },
        onbeforerender: function (context) {
            NS.data.unitList = context.unitList.record.map(function (item) {
                return Object.assign({}, item, { id: item.contactUnitCode, contactUnitId: item.id, name: item.contactUnitName });
            });
        },
        onafterrender: function (context) {
        }
    });
}());

